<template>
    <div style="height: 100%;">
        <el-container style="height: 100%; border: 1px solid #eee">
            <el-aside :width="sidewidth + 'px'" style="background-color: rgb(238, 241, 246);overflow-x:hidden;">
                <el-menu :default-openeds="['1', '3']" background-color="rgb(48,65,78)" text-color="#fff"
                    :collapse="isCollapse" :collapse-transition="false" style="min-height: 100%;" router>
                    <div style="height: 60px; line-height: 60px; text-align: center;">
                        <img src="../assets/logo.png" alt=""
                            style="width: 20px; position: relative; top: 5px; right: 5px;">
                        <b v-show="logoTextShow" style=" color: white;">车辆管理系统</b>
                    </div>
                    <el-menu-item index="/index/usermanage" ><i class="el-icon-menu"></i> <span>用户管理</span></el-menu-item>
                    <el-menu-item index="/index/userhobby"><i class="el-icon-setting"></i> <span>用户爱好</span></el-menu-item>
                    <el-submenu index="2">
                        <template slot="title">
                            <span slot="title">导航二</span>
                        </template>
                        <el-menu-item-group>
                            <template slot="title">分组一</template>
                            <el-menu-item index="2-1">选项1</el-menu-item>
                            <el-menu-item index="2-2">选项2</el-menu-item>
                        </el-menu-item-group>

                    </el-submenu>
                    <el-submenu index="3">
                        <template slot="title">
                            <span slot="title">导航三</span>
                        </template>
                        <el-menu-item-group>
                            <template slot="title">分组一</template>
                            <el-menu-item index="3-1">选项1</el-menu-item>
                            <el-menu-item index="3-2">选项2</el-menu-item>
                        </el-menu-item-group>

                    </el-submenu>
                </el-menu>
            </el-aside>
            <el-container>
                <el-header style="font-size: 12px; display: flex;">
                    <div style="font-size: 18px; width: 91%;">
                        <span :class="collapseBtnClass" @click="clickcollapse"></span>
                    </div>
                    <el-dropdown>
                        <i class="el-icon-setting" style="margin-right: 15px"></i>
                        <el-dropdown-menu slot="dropdown">
                            <el-dropdown-item>查看</el-dropdown-item>
                            <el-dropdown-item>新增</el-dropdown-item>
                            <el-dropdown-item>删除</el-dropdown-item>
                        </el-dropdown-menu>
                    </el-dropdown>
                    <span style="width: 50px;">王小虎</span>
                    <div><el-avatar  class="block" :size="40" :src="circleUrl"></el-avatar></div>
                </el-header>
                <el-main>
                    <router-view />
                </el-main>
            </el-container>
        </el-container>
    </div>
</template>
<style>
.el-header {
    background-color: #B3C0D1;
    color: #333;
    line-height: 60px;
}

.el-aside {
    color: #333;
}
</style>
<script>

export default {
    data() {
        return {
            collapseBtnClass: 'el-icon-s-fold',
            isCollapse: false,
            sidewidth: 200,
            logoTextShow: true,
            circleUrl:"https://cube.elemecdn.com/3/7c/3ea6beec64369c2642b92c6726f1epng.png"
        }
    },
    methods: {
        clickcollapse() {
            this.isCollapse = !this.isCollapse;
            //宽度设置
            if (this.isCollapse) {
                this.sidewidth = 64;
                this.logoTextShow = false;
            }
            else {
                this.sidewidth = 200;
                this.logoTextShow = true;
            }
            //图标设置
            if (this.collapseBtnClass == 'el-icon-s-fold')
                this.collapseBtnClass = 'el-icon-s-unfold';
            else
                this.collapseBtnClass = 'el-icon-s-fold';
        }
    }
};
</script>
<style>
.block {
    position: relative;
    top: 10px;
}
</style>